#!/bin/bash
# 加到crontab里面去,1分钟跑一次 * * * * * sh /data/app/code/zdsx/alarm-console/scripts/check_api.sh >>  /data/logs/crontab_nginx_logs.log
# 检测Java进程是否正常，如果不正常就重启
PID=$(ps -ef | grep "/usr/local/nginx/sbin/nginx" | grep -v grep | awk '{print $2}')
#echo $PID
# 检查是否找到了进程ID
if [ -z "$PID" ]; then
    echo "没有找到名为zdsx-api的进程。"
    echo "开始重启nginx"
    #nohup /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf >> /data/logs/crontab_nginx_logs.log 2>&1 &
    echo "重启nginx结束"
else
    echo "找到名为nginx的进程，进程ID为：$PID"
fi
